package com.ppt.android.base.utils

import java.net.URI
import java.net.URLDecoder
import java.nio.charset.StandardCharsets

/**
 *
 * @author ZouJiaCai
 * @since 2023/8/10 16:47
 */
object UrlUtils {

    fun parseUrl(url: String): Map<String, String>? {
        return try {
            val uri = URI(url)
            val query = uri.query
            val params = query.split("&").associate {
                val (key, value) = it.split("=")
                key to URLDecoder.decode(value, StandardCharsets.UTF_8.name())
            }
            params
        }catch (e: Exception){
            e.printStackTrace()
            null
        }

    }
}